/*
 * Copyright (c) 2022 Huawei Device Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
import { BaseMatcher } from '../BaseMatcher.js';
import { AnyOf } from '../core/AnyOf.js';
import { IsNull } from '../core/IsNull.js';
/**
 * Matches blank Strings (and null).
 */
export class IsBlankString extends BaseMatcher {
    constructor() {
        super();
    }
    matches(item) {
        return IsBlankString.REGEX_WHITESPACE.test(item.toString());
    }
    describeTo(description) {
        description.appendText("a blank string");
    }
    /**
     * Creates a matcher of {@link String} that matches when the examined string contains
     * zero or more whitespace characters and nothing else.
     * For example:
     * <pre>assertThat("  ", is(blankString()))</pre>
     *
     * @return The matcher.
     */
    static blankString() {
        return IsBlankString.BLANK_INSTANCE;
    }
    /**
     * Creates a matcher of {@link String} that matches when the examined string is <code>null</code>, or
     * contains zero or more whitespace characters and nothing else.
     * For example:
     * <pre>assertThat(((String)null), is(blankOrNullString()))</pre>
     *
     * @return The matcher.
     */
    static blankOrNullString() {
        return IsBlankString.NULL_OR_BLANK_INSTANCE;
    }
}
IsBlankString.BLANK_INSTANCE = new IsBlankString();
IsBlankString.NULL_OR_BLANK_INSTANCE = AnyOf.anyOfMatches(IsNull.nullValue(), IsBlankString.BLANK_INSTANCE);
IsBlankString.REGEX_WHITESPACE = new RegExp("\\s");
